package com.drinks.yiniang.adapter.search;

import android.content.Context;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseViewHolder;
import com.drinks.yiniang.R;
import com.drinks.yiniang.adapter.base.BaseMultiItemQuickRCVAdapter;
import com.drinks.yiniang.adapter.base.BaseQuickRCVAdapter;
import com.drinks.yiniang.entity.goods.SearchGoodsJson;
import com.drinks.yiniang.utils.GlideUtils;
import com.hansen.library.ui.widget.image.RatioRoundImageView;
import com.hansen.library.utils.CommonUtils;
import com.hansen.library.utils.StringUtils;

import java.util.List;

import static com.drinks.yiniang.entity.goods.SearchGoodsJson.ITEM_TYPE_SEARCH_GOODS_LIST;
import static com.drinks.yiniang.entity.goods.SearchGoodsJson.ITEM_TYPE_SEARCH_GOODS_TITLE;

/**
 * 搜索商品adapter
 * @author han
 * @date 2019/8/30
 */
public class SearchGoodsTagAdapter extends BaseQuickRCVAdapter<SearchGoodsJson.SearchGoodsList, BaseViewHolder> {

    private StringBuilder mBuilder;

    public SearchGoodsTagAdapter(Context mContext, @Nullable List<SearchGoodsJson.SearchGoodsList> data) {
        super(R.layout.item_search_goods_tag, data);

        mBuilder = new StringBuilder();
    }

    @Override
    protected void convert(BaseViewHolder helper, SearchGoodsJson.SearchGoodsList item) {
        GlideUtils.loadGoodsList(mContext, (RatioRoundImageView) helper.getView(R.id.iv_sgd_tag_cover), item.getCover_url());

        //商品名称
        helper.setText(R.id.tv_sgd_tag_name, item.getName());
        //推荐语
        helper.setText(R.id.tv_sgd_tag_slogan, item.getRecommend_reason());
        //价格
        mBuilder = new StringBuilder();
        mBuilder.append("¥");
        mBuilder.append(StringUtils.getGoodsPrice(item.getApp_price(), item.getActivity_price()));
        helper.setText(R.id.tv_sgd_tag_price, mBuilder);
    }
}
